﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace RATSharp.Validator
{
    class StringInputTimeValidator : IInputValidator<DateTime>
    {
        private string pattern;

        public StringInputTimeValidator(string pattern)
        {
            this.pattern = pattern;
        }


        public bool validate(string input, out DateTime output)
        {
            output = new DateTime();
            try
            {
                output = DateTime.ParseExact(input, pattern,
                                     null);
                return true;

            }
            catch (ArgumentNullException ex)
            {
                return false;
            }
            catch (FormatException ex)
            {
                return false;
            }
        }

    }
}
